<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>登录</title> 
    <link rel="stylesheet" href="./css/login.css">
</head>
<body>
    <div class="main">
        <div class="register">
            <div class="left">
                <img src="./images/chahua.png" alt="">
            </div>
            <div class="right">
                <div class="from">
                    <div class="title">
                        <h2>盈链科技</h2>
                        <span>盈聚智慧，链通价值</span>
                    </div>
                    <div class="newLogin">
                        <a href="./register.php">注册新账号</a>
                    </div>
                    <div class="login">
                        <img src="./images/yonghu.png" alt="">
                        <input type="mobile" placeholder="请输入账号/手机号" id="mobile">
                    </div>
                    <div class="Verification">
                        <img src="./images/mima.png" alt="">
                        <input class="password" type="Password" placeholder="请输入登录密码" id="password">
                        <img class="passwordeye" src="./images/eye.png" alt="">
                    </div>
                    <div class="yes">
                        <div class="left">
                            <span><a href="">快速登陆</a></span>
                        </div>
                        <div class="right1">
                            <span>已有账号?</span>&nbsp;
                            <a href="./register.php">立即注册</a>
                        </div>
                    </div>
                    <a href="#" id="btn" style="color: #fff;"><div class="immediatelyLogin">
                        登陆
                    </div></a>
                </div>
            </div>
        </div>      
    </div>
</body>
</html>
<script src="./js/jquery-1.12.4.min.js"></script>
<script src="./js/function.js"></script>
<script type="text/javascript" src="../public/lib/layer/2.4/layer.js"></script>
<script>
$(function () {
    $('.passwordeye').click(function(){
        if($('.password').attr('type')=='Password'){
            $('.password').attr('type','text')
        }else{
            $('.password').attr('type','Password')
        }
    })

    var url = 'http://'+document.domain+"/index/login/login";
    $('#btn').click(function(){
        var mobile = $('#mobile').val();
        var password = $('#password').val();
        if (mobile == false) {
            layer.msg('请填写手机号！');
            return false;
        }
        if (password == false) {
            layer.msg('请填写账号密码！');
            return false;
        }
        $.ajax({
            type: 'POST',
            url: url,
            data:{mobile:mobile,password:password},
            dataType: 'json',
            success: function(data){
                if (data.result==400) {
                    layer.msg(data.msg);
                    console.log('失败')
                }else{
                    layer.msg(data.msg);
                    setCookie('user_id',data.data['user_id']);
                    window.location.href="index.php";
                }
            },
        })
    })
})
</script>